package com.shop.common.util;

import java.util.Random;

/**
 * @author ghy
 * @version 1.0
 * @date 2020-10-29
 */
public class CodeUtils {


    public static String getCheckCode4() {
        String ZiMu = "1234567890";
        String result = "";
        Random random = new Random();
        for (int i = 0; i < 4; i++) {
            int index = random.nextInt(ZiMu.length());
            char c = ZiMu.charAt(index);
            result += c;
        }
        return result;

    }

    public static String getCheckCode6() {
        String ZiMu = "1234567890";
        String result = "";
        Random random = new Random();
        for (int i = 0; i < 6; i++) {
            int index = random.nextInt(ZiMu.length());
            char c = ZiMu.charAt(index);
            result += c;
        }
        return result;

    }

    public static void main(String[] args) {
        for (int i = 0; i < 10000; i++) {
            System.out.println(getCheckCode4());
        }
    }

}
